package com.chujian.framework.ws.support.srv;

import com.chujian.framework.ws.WsMsg;
import com.chujian.framework.ws.IWsSender;

/**
 * ws服务端消息推动
 */
public class WsSrvMsgPusher {

    private final IWsSender sender;

    public WsSrvMsgPusher(IWsSender sender) {
        this.sender = sender;
    }

    /**
     * 智能推送消息
     *
     * @param msg
     */
    public void pushMsg(WsMsg msg) throws Exception {
        sender.send(msg);
    }

    /**
     * 不缓冲，直接发送消息
     *
     * @param msg
     * @throws Exception
     */
    public void pushDirectMsg(WsMsg msg) throws Exception {
        sender.sendDirect(msg);
    }
}
